#ifndef EMBED_H_
#define EMBED_H_

#include "libepc.h"
#include "utypes.h"

#include <stdio.h>
	
//ints
#define T0_IRQ    0  ///< Timer 0
#define KBD_IRQ   1  ///< keyboard       
#define COM2_IRQ  3  ///< serial port 2 
#define COM1_IRQ  4  ///< serial port 1  
#define FLP_IRQ   6  ///< floppy         
#define LPT_IRQ   7  ///< parallel port  
#define RTC_IRQ   8  ///< realtime clock 
#define MOUSE_IRQ 12 ///< mouse          
#define FPU_IRQ   13 ///< Floating point 
#define DISK1_IRQ 14 ///< Hard disk controller 1   
#define DISK2_IRQ 15 ///< Hard disk controller 2  

//timer
#define TIMER_0      0x40 ///< Adress of Timer0 divider
#define TIMER_CTRL   0x43 ///< The address of the timer control register

#define TIMER_CLK    1193181 ///< The timers input frequency
#define LCOM_MODE  0x36    ///< Control byte: LSB followed by MSB, mode 3, binary count 

#define PIC1_MASK 0x21  ///< PIC1 register address to read/write interrupt mask */
#define PIC2_MASK 0xA1  ///< PIC2 register address to read/write interrupt mask */

#define IRQ_MASK_BIT(irq) ((irq) < 8 ? 1 << (irq) : (1 << (irq)) >> 8)

#define HRES 1024
#define VRES 768
#define COR_DE_TIJOLO 113

#define CHR_H 16


extern int msec;
extern int sec;
void asm_wait(void);

/*typedef struct {
  int x, y;            ///< current sprite position
  int width, height;   ///< sprite dimensions
  int xspeed, yspeed;  ///< sprite current speed in the x and y direction
  char *map;          ///< the sprite pixmap (use read_xpm())
} Sprite;*/


//ints
void mask_pic(int irq);
void unmask_pic(int irq);

//timer
void t0_init(int mode);
void t0_load(int value);
int get_divider(float freq);

//video-graphics
void set_pixel(int x, int y, int color, char *base);
int get_pixel(int x, int y, char *base);
void clear_screen(char color, char *base);
void draw_line(int xi, int yi, int xf, int yf, int color, char *base);
void drawCharAt(char c, int x, int y, int fore_color, int back_color,
				int char_scale, char *video_base, char *table);			
void drawStringAt(char* str, int x, int y, int fore_color, int back_color,
				int char_scale, char *video_base, char *table);			
void drawIntAt(int num, int x, int y, int fore_color, int back_color,
				int char_scale, char *video_base, char *table);
/*			
//sprites
Sprite* create_sprite(char *pic[], char *base);
void delete_sprite(Sprite *sprt, char *base);
void destroy_sprite(Sprite *sprt, char *base);*/
//void draw_sprite(Sprite *sprt, char *base);
#endif
